package com.focusai.efairy.ui.adapter.announce;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.focusai.efairy.R;
import com.focusai.efairy.model.announce.UpLoadAnnounceItem;
import com.focusai.efairy.ui.adapter.base.BaseRecyclerAdapter;
import com.focusai.efairy.ui.adapter.base.BaseRecyclerViewHolder;

/**
 * Created by luo_guangwen on 2017/10/26.
 */

public class ImageAdapter extends BaseRecyclerAdapter<UpLoadAnnounceItem.AnnounceImageItem> {


    public ImageAdapter(Context context) {
        super(context);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_image;
    }

    @Override
    protected void onBindBaseRecyclerViewHolder(BaseRecyclerViewHolder holder, int position) {
//        ImageLoaderFactory.getImageLoader().loadImage(mContext, holder.getImageView(R.id.image),
//                mList.get(position).efairyannouncementimage_imgurl, ImageView.ScaleType.FIT_XY);

        Glide.with(mContext).load(mList.get(position).efairyannouncementimage_imgurl)
                .transition(DrawableTransitionOptions.withCrossFade(300))
                .apply(getOptions()).into( holder.getImageView(R.id.image));
    }

    private RequestOptions getOptions() {
        RequestOptions options = new RequestOptions()
                .centerCrop()
                .placeholder(R.drawable.image_default_pic)
                .error(R.drawable.dm_img_forpic_normal)
                .priority(Priority.HIGH)
                .fitCenter()
                .dontAnimate()
                .dontTransform()
                .override(800, 800)
                .diskCacheStrategy(DiskCacheStrategy.ALL);
        return options;
    }

}
